package main

import (
	"gitee.com/zjlsliupei/gweb-cli/create_module"
	"gitee.com/zjlsliupei/gweb-cli/skeleton"
	"github.com/beego/beego/v2/core/logs"
	"gopkg.in/alecthomas/kingpin.v2"
	"os"
)

var (
	app                = kingpin.New("gweb-cli", "gweb脚手架工具.")
	createModule       = app.Command("createModule", "生成模块代码")
	createModuleConfig = createModule.Flag("config", "生成模块所需的配置文件。如：./*.conf 或 ./demo.conf").Required().Short('c').String()
	createModuleOut    = createModule.Flag("out", "生成代码的目录。 默认当前路径").Default("./").Short('o').String()

	_init    = app.Command("init", "初始化框架")
	_initOut = _init.Flag("out", "克隆代码的目录。 默认当前路径").Default("./").Short('o').String()
)

func main() {
	switch kingpin.MustParse(app.Parse(os.Args[1:])) {
	// createModule
	case createModule.FullCommand():
		if *createModuleConfig != "" && *createModuleOut != "" {
			create_module.BatchCreateModule(*createModuleConfig, *createModuleOut)
			logs.Info("createModel Success!")
		}
	// _init
	case _init.FullCommand():
		if *_initOut != "" {
			skeleton.Init(*_initOut)
			logs.Info("init Success!")
		}

	}

}
